package ar.edu.utn.frba.dds.opendesigners.format;

import java.text.ParsePosition;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Collection;
import java.util.Date;
import java.util.Iterator;

import ar.edu.utn.frba.dds.opendesigners.exception.BusinessException;

public class FormatDateFlex implements FormatDate{
	
	private Collection<FormatDateHard> formats;
	
	public FormatDateFlex(Collection<FormatDateHard> formats) {
		this.formats = formats;
	}
	
	@Override
	public Calendar create(String stringDate) {
		for (FormatDateHard format : this.formats) {
			try {
				return format.create(stringDate);			
			} catch (BusinessException e) {
				// TODO: handle exception
			}
		}
		throw new BusinessException("No se puede parsear con ningun formato flexible");
	}
}
